package grammar.parser.stmt;

import error.processing.MyErrorProcessing;
import exp.parser.Exp;
import word.parser.WordElement;

public class ExpStmt extends Stmt {
    private final Exp exp;

    public ExpStmt(Exp exp) {
        this.exp = exp;
    }


    @Override
    public void execute() {
        if (exp != null) {
            exp.getValue();
        }
    }

    // 在stmt中直接调用了Exp.buildExp()
    // 不需要该方法了
    public static ExpStmt buildExpStmt() {
        Exp exp = Exp.buildExp();
        if (getAnalyzingWord().getType() != WordElement.WordType.SEMICN) {
            MyErrorProcessing.buildErrorProcessing(MyErrorProcessing.ErrorType.i,
                    getAnalyzingWord(-1));
        } else {
            analyzeNextWord();
        }
        return new ExpStmt(exp);
    }

}
